package main

import (
	"context"
	"fmt"
	"google.golang.org/grpc"
	"mxshop_srvs/user_srv/proto"
	"strconv"
)

var userClient proto.UserClient
var con *grpc.ClientConn

func init() {
	var err error
	con, err = grpc.Dial("127.0.0.1:50051", grpc.WithInsecure())
	if err != nil {
		panic(err)
	}
	userClient = proto.NewUserClient(con)
}

func testCreate() {

	i := 20
	for i < 30 {
		userInfo := proto.CreateUserInfo{
			NickName: "张三" + strconv.Itoa(i),
			PassWord: "123456",
			Mobile:   "131888888" + strconv.Itoa(i)}
		resp, err := userClient.CreateUser(context.Background(), &userInfo)
		if err != nil {
			fmt.Println(err)
		}
		fmt.Println(resp)
		i++
	}
}

func validate() {
	resp, err := userClient.CheckPassWord(context.Background(), &proto.PasswordCheckInfo{
		PassWord:          "123456",
		EncryptedPassWord: "$pbkdf2-sha512$bX0bq4Dk4bg1URW3$8f9f63457cb418d1da9dbe580aa46e55fe127418dae33e934c7abc2580dab8e7",
	})
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(resp)

}
func main() {
	//testCreate()
	validate()
	con.Close()
}
